﻿namespace MDXStudio
{
    using MDXParser;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class Options : Form
    {
        private Button buttonOK;
        private CheckBox checkBoxColorFunction;
        private IContainer components;
        private GroupBox groupBoxColoring;
        private GroupBox groupBoxLists;
        private Label label1;
        private FormatOptions m_FormatOptions;
        private NumericUpDown numericUpDownIndent;
        private Panel panelFormat;
        private RadioButton radioButtonNLAfterComma;
        private RadioButton radioButtonNLBeforeComma;
        private TreeView treeViewOptions;

        public Options(FormatOptions fo)
        {
            this.InitializeComponent();
            this.m_FormatOptions = fo;
            this.radioButtonNLBeforeComma.Checked = this.m_FormatOptions.CommaBeforeNewLine;
            this.radioButtonNLAfterComma.Checked = !this.m_FormatOptions.CommaBeforeNewLine;
            this.numericUpDownIndent.Value = this.m_FormatOptions.Indent;
            this.checkBoxColorFunction.Checked = this.m_FormatOptions.ColorFunctionNames;
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void checkBoxColorFunction_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox box = sender as CheckBox;
            this.m_FormatOptions.ColorFunctionNames = box.Checked;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            System.Windows.Forms.TreeNode node = new System.Windows.Forms.TreeNode("Format");
            System.Windows.Forms.TreeNode node2 = new System.Windows.Forms.TreeNode("MDX", new System.Windows.Forms.TreeNode[] { node });
            this.treeViewOptions = new TreeView();
            this.panelFormat = new Panel();
            this.buttonOK = new Button();
            this.radioButtonNLBeforeComma = new RadioButton();
            this.radioButtonNLAfterComma = new RadioButton();
            this.groupBoxLists = new GroupBox();
            this.numericUpDownIndent = new NumericUpDown();
            this.label1 = new Label();
            this.checkBoxColorFunction = new CheckBox();
            this.groupBoxColoring = new GroupBox();
            this.panelFormat.SuspendLayout();
            this.groupBoxLists.SuspendLayout();
            this.numericUpDownIndent.BeginInit();
            this.groupBoxColoring.SuspendLayout();
            base.SuspendLayout();
            this.treeViewOptions.Location = new Point(13, 13);
            this.treeViewOptions.Name = "treeViewOptions";
            node.Name = "optionsNodeFormat";
            node.Text = "Format";
            node2.Name = "optionsNodeMDX";
            node2.Text = "MDX";
            this.treeViewOptions.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { node2 });
            this.treeViewOptions.Size = new Size(0xcb, 0x11b);
            this.treeViewOptions.TabIndex = 0;
            this.panelFormat.Controls.Add(this.groupBoxColoring);
            this.panelFormat.Controls.Add(this.label1);
            this.panelFormat.Controls.Add(this.numericUpDownIndent);
            this.panelFormat.Controls.Add(this.groupBoxLists);
            this.panelFormat.Location = new Point(0xec, 0x10);
            this.panelFormat.Name = "panelFormat";
            this.panelFormat.Size = new Size(0x167, 0xec);
            this.panelFormat.TabIndex = 1;
            this.buttonOK.DialogResult = DialogResult.Cancel;
            this.buttonOK.Location = new Point(520, 0x111);
            this.buttonOK.Name = "buttonOK";
            this.buttonOK.Size = new Size(0x4b, 0x17);
            this.buttonOK.TabIndex = 2;
            this.buttonOK.Text = "OK";
            this.buttonOK.UseVisualStyleBackColor = true;
            this.buttonOK.Click += new EventHandler(this.buttonOK_Click);
            this.radioButtonNLBeforeComma.AutoSize = true;
            this.radioButtonNLBeforeComma.Checked = true;
            this.radioButtonNLBeforeComma.Location = new Point(14, 0x13);
            this.radioButtonNLBeforeComma.Name = "radioButtonNLBeforeComma";
            this.radioButtonNLBeforeComma.Size = new Size(0xbc, 0x11);
            this.radioButtonNLBeforeComma.TabIndex = 0;
            this.radioButtonNLBeforeComma.TabStop = true;
            this.radioButtonNLBeforeComma.Text = "Comma at the beginning of the line";
            this.radioButtonNLBeforeComma.UseVisualStyleBackColor = true;
            this.radioButtonNLBeforeComma.CheckedChanged += new EventHandler(this.radioButtonNLBeforeComma_CheckedChanged);
            this.radioButtonNLAfterComma.AutoSize = true;
            this.radioButtonNLAfterComma.Location = new Point(14, 0x2a);
            this.radioButtonNLAfterComma.Name = "radioButtonNLAfterComma";
            this.radioButtonNLAfterComma.Size = new Size(160, 0x11);
            this.radioButtonNLAfterComma.TabIndex = 1;
            this.radioButtonNLAfterComma.Text = "Comma at the end of the line";
            this.radioButtonNLAfterComma.UseVisualStyleBackColor = true;
            this.radioButtonNLAfterComma.CheckedChanged += new EventHandler(this.radioButtonNLAfterComma_CheckedChanged);
            this.groupBoxLists.Controls.Add(this.radioButtonNLBeforeComma);
            this.groupBoxLists.Controls.Add(this.radioButtonNLAfterComma);
            this.groupBoxLists.Location = new Point(14, 14);
            this.groupBoxLists.Name = "groupBoxLists";
            this.groupBoxLists.Size = new Size(0x147, 0x4d);
            this.groupBoxLists.TabIndex = 2;
            this.groupBoxLists.TabStop = false;
            this.groupBoxLists.Text = "Multiline list formatting";
            this.numericUpDownIndent.Location = new Point(0x1c, 0x7e);
            this.numericUpDownIndent.Name = "numericUpDownIndent";
            this.numericUpDownIndent.Size = new Size(0x2c, 20);
            this.numericUpDownIndent.TabIndex = 3;
            this.numericUpDownIndent.ValueChanged += new EventHandler(this.numericUpDownIndent_ValueChanged);
            this.label1.AutoSize = true;
            this.label1.Location = new Point(14, 110);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x3a, 13);
            this.label1.TabIndex = 4;
            this.label1.Text = "Indent size";
            this.checkBoxColorFunction.AutoSize = true;
            this.checkBoxColorFunction.Location = new Point(11, 0x1c);
            this.checkBoxColorFunction.Name = "checkBoxColorFunction";
            this.checkBoxColorFunction.Size = new Size(0x7d, 0x11);
            this.checkBoxColorFunction.TabIndex = 5;
            this.checkBoxColorFunction.Text = "Color function names";
            this.checkBoxColorFunction.UseVisualStyleBackColor = true;
            this.checkBoxColorFunction.CheckedChanged += new EventHandler(this.checkBoxColorFunction_CheckedChanged);
            this.groupBoxColoring.Controls.Add(this.checkBoxColorFunction);
            this.groupBoxColoring.Location = new Point(0x11, 0xa1);
            this.groupBoxColoring.Name = "groupBoxColoring";
            this.groupBoxColoring.Size = new Size(0x144, 60);
            this.groupBoxColoring.TabIndex = 6;
            this.groupBoxColoring.TabStop = false;
            this.groupBoxColoring.Text = "Coloring";
            base.AcceptButton = this.buttonOK;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.CancelButton = this.buttonOK;
            base.ClientSize = new Size(0x268, 0x13e);
            base.Controls.Add(this.buttonOK);
            base.Controls.Add(this.panelFormat);
            base.Controls.Add(this.treeViewOptions);
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "Options";
            base.ShowIcon = false;
            base.SizeGripStyle = SizeGripStyle.Hide;
            this.Text = "Options";
            base.Load += new EventHandler(this.Options_Load);
            this.panelFormat.ResumeLayout(false);
            this.panelFormat.PerformLayout();
            this.groupBoxLists.ResumeLayout(false);
            this.groupBoxLists.PerformLayout();
            this.numericUpDownIndent.EndInit();
            this.groupBoxColoring.ResumeLayout(false);
            this.groupBoxColoring.PerformLayout();
            base.ResumeLayout(false);
        }

        private void numericUpDownIndent_ValueChanged(object sender, EventArgs e)
        {
            NumericUpDown down = sender as NumericUpDown;
            this.m_FormatOptions.Indent = (int) down.Value;
        }

        private void Options_Load(object sender, EventArgs e)
        {
            this.treeViewOptions.ExpandAll();
        }

        private void radioButtonNLAfterComma_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton button = sender as RadioButton;
            this.m_FormatOptions.CommaBeforeNewLine = !button.Checked;
        }

        private void radioButtonNLBeforeComma_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton button = sender as RadioButton;
            this.m_FormatOptions.CommaBeforeNewLine = button.Checked;
        }
    }
}

